<?php

namespace app\api\controller;

use app\common\controller\Api;
use app\api\controller\My;
use app\common\controller\MyHelp;
use think\Db;

/**
 * 示例接口
 */
class Feihuo5 extends Api
{

    //如果$noNeedLogin为空表示所有接口都需要登录才能请求
    //如果$noNeedRight为空表示所有接口都需要验证权限才能请求
    //如果接口已经设置无需登录,那也就无需鉴权了
    //
    // 无需登录的接口,*表示全部
    protected $noNeedLogin = ['*'];
    // 无需鉴权的接口,*表示全部
    protected $noNeedRight = ['*'];
    /**
     * 删除数据库
     */
    public function qq_del()
    {
        // $rst =  db::table('fa_feihuo_qq')->delete();

        $qqs = $this->request->request('qqs');

        $rst =  db::table('fa_feihuo_qq5')->where('qq', 'in', $qqs)->delete();

        return $this->success('删除成功:' . $rst);
    }
    /**
     * 查询数量
     */
    public function qq_num()
    {
        // $rst =  db::table('fa_feihuo_qq')->delete();



        $rst =  db::table('fa_feihuo_qq5')->count('id');

        return $this->success('查询成功', $rst);
    }

    /**
     * 清空数据库
     */
    public function qq_clear()
    {
        $rst =  db::table('fa_feihuo_qq5')->query('TRUNCATE TABLE fa_feihuo_qq5');
        // dump($rst);
        // $qqs = $this->request->request('qq');

        // $rst =  db::table('fa_feihuo_qq')->where('qq', 'in', $qqs)->delete();

        return $this->success('执行成功');
    }
    /**
     * 清空数据库
     */
    public function qq_add()
    {
        $qqs = $this->request->request('qqs');
        $qq_aqq = explode(',', $qqs);
        $das = [];
        $num = 0;
        foreach ($qq_aqq as $key => $value) {
            if (strlen($value) > 10) {
                continue;
            }
            $da = [
                'qq' => $value,
                'createtime' => time()
            ];
            $das[] = $da;
            $num++;
        }
        db::table('fa_feihuo_qq5')->insertAll($das, true);
        return $this->success('添加成功:' . $num);
    }
    /**
     * 查询数据
     */
    public function qq_query()
    {
        $qqs = $this->request->request('qqs');

        $rst =  db::table('fa_feihuo_qq5')->where('qq', 'in', $qqs)->select();
        $data = '';
        foreach ($rst as $key => $value) {
            $data .= $value['qq'] . ',';
        }

        return $this->success('查询成功', ['qqs' => $data, 'jsonData' => $rst]);
    }
}
